import sim, sim_items, main
from util import *
import random

class FeatherlightPrefix(sim_items.Prefix):
    def __init__(self):
        super(FeatherlightPrefix, self).__init__(
            "featherlight", # name
            "Certain armor-smiths have mastered the art of using foreign "
            "light weight cured-leathers and tempered alloys.  The result is a "
            "suit of armor as strong as any other but significantly lighter."
        )

    def initialize(self, wearable):
        if not isinstance(wearable, sim_items.Armor):
            raise ValueError('Tried to apply %r to non-armor item: %r' % (self,
                wearable))
        if 'body' not in wearable.wearSlots:
            return 
        super(FeatherlightPrefix, self).initialize(wearable)
        
        multiplier = 0.25 + 0.2*random.random()
        self.weightMod = multiplier * wearable.weight

        wearable.weight -= self.weightMod

    def remove(self, wearable):
        super(FeatherlightPrefix, self).remove(wearable)
        wearable.weight += self.weightMod

#========================================
thingClass = FeatherlightPrefix
